public class Solution {
    public static int strStr(String haystack, String needle) {
        char[] tmp1 = haystack.toCharArray();
        char[] tmp2 = needle.toCharArray();
        int j = 0;
        while (j < tmp1.length) {
            if (tmp1[j] != tmp2[0]) {
                j++;
            } else {
                int tmp = j;
                int i = 0;
                while (tmp < tmp1.length && tmp1[tmp++] == tmp2[i++]) {
                    if (i == tmp2.length) {
                        return j;
                    }
                }
                j++;
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        String str1 = "leetcoed";
        String str2 = "leeto";
      int ret = strStr(str1,str2);
        System.out.println(ret);
    }
}
